package com.zoke.nebbox.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zoke.neb.avatar.model.NebFile;
import com.zoke.nebbox.R;
import com.zoke.nebbox.tools.Util;

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * Created by wulijie on 2018/6/8.
 */
public class NebFileAdapter extends BaseQuickAdapter<NebFile, BaseViewHolder> {
    public NebFileAdapter(@Nullable List<NebFile> data) {
        super(R.layout.item_dapp, data);
    }

    private SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");


    @Override
    protected void convert(BaseViewHolder helper, NebFile item) {
        DecimalFormat ff = new DecimalFormat("##0.00");
        ImageView imageView = helper.getView(R.id.headIv);
        imageView.setImageResource(Util.getRes(item.name));
        helper.addOnClickListener(R.id.tv_go);
        float size = Float.parseFloat(item.size) / (1024.0f * 1024f);
        helper.setText(R.id.tv_title, item.name)
                .setText(R.id.tv_zh, item.userId)
                .setText(R.id.tv_size, ff.format(size) + " MB" + "    " + formatter.format(new Date(Long.parseLong(item.ts) * 1000)));
    }
}
